﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace EyeOfTheWorld
{
    public class Database
    {
        public void Obliviate()
        {
            foreach (var page in allPages)
            {
                page.Value.State = "unvisited";
                page.Value.Label = string.Empty;
            }
        }

        static Database instance;

        private Database()
        {
        }

        public static Database Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new Database();
                }
                return instance;
            }
        }

        public Dictionary<string, Page> allPages = new Dictionary<string, Page>();

        public void AddPage(string address)
        {
            allPages.Add(address, new Page(address));
        }

        public void AddLink(string from, string to, string label)
        {
            Page fromPage = allPages[from];
            Page toPage = allPages[to];
            fromPage.Connections.Add(new Link(fromPage, toPage, label));
        }
    }
}